﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ViewTransactionDone : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            if (Session["admin"] != null)
            {
                load_data_thongke();
                load_data_byDay();

            }
            else
            {
                Response.Redirect("blankAdmin.aspx");
            }
            
        }
    }
    private void load_data_thongke()
    {
        bussiness bus = new bussiness();
        grvthongke.DataSource = bus.getview_thongKeGiaoDichHoanThanhTheoCustomer();
        grvthongke.DataBind();
    }
    private void Load_data_chitiet(int customerId)
    {
        bussiness bus = new bussiness();
        grvTransaction.DataSource = bus.getLogSentMailByCustomerId(customerId);
        grvTransaction.DataBind();
    }
    private void Load_data_chitietByDay(int customerId)
    {
        bussiness bus = new bussiness();
        grvTransaction.DataSource = bus.getLogSentMailByCustomerIdByDay(customerId);
        grvTransaction.DataBind();
    }
    private void load_data_byDay()
    {
        bussiness bus = new bussiness();
        grvByDay.DataSource = bus.getview_thongKeGiaoDichHoanThanhTheoCustomerByDay();
        grvByDay.DataBind();
    }
    protected void grvTransaction_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grvTransaction.PageIndex = e.NewPageIndex;
        Load_data_chitiet(customerId);
    }
    int customerId = 0;
    protected void grvthongke_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        GridViewRow row = grvthongke.Rows[e.NewSelectedIndex];
        customerId = Convert.ToInt32(row.Cells[0].Text);
        Load_data_chitiet(customerId);
    }
    protected void grvthongke_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grvthongke.PageIndex = e.NewPageIndex;
        load_data_thongke();
    }
    protected void grvByDay_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        GridViewRow row = grvByDay.Rows[e.NewSelectedIndex];
        customerId = Convert.ToInt32(row.Cells[0].Text);
        Load_data_chitietByDay(customerId);
       
    }
    protected void grvByDay_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grvByDay.PageIndex = e.NewPageIndex;
        load_data_byDay();
    }
}